#include <stdio.h>

#define N 5
int main()
{
	char s[15] = { "PAYPALISHIRING" };
	int c = (sizeof(s) / sizeof(char)) - 1;
	printf("%d\n", c);
	int i, k,j,h;
	int d = 2 * (N - 1);
	for (k = 0; k < N; k++)
	{
		if (k != N - 1&&k!=0)
		{
			for (i = k,j=1; i < c; )
			{
				if (j == 1)
				{
					printf("%c", s[i]);
					for (h = 0; h < d - 2 * k-1; h++)
					{
						printf(" ");
					}
					i += (d - 2 * k);
					j = 0;
				}
				else {
					printf("%c", s[i]);
					for (h = 0; h <2 * k-1; h++)
					{
						printf(" ");
					}
					i+=2*k;
					j = 1;
				}
			}
		}
		else {
			for (i = k; i < c; i += d)
			{
				printf("%c", s[i]);
				for (h = 0; h < d-1;h++)
				{
					printf(" ");
				}
			}
		}
		printf("\n");
	}

	return 0;
}